//
//  UIButton+Extension.swift
//  TYBlog
//
//  Created by 杨远鹏 on 16/9/22.
//  Copyright © 2016年 TY. All rights reserved.
//

import UIKit

extension UIButton{
    convenience init(imageName: String, backgroudImageName: String){
        self.init()
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Selected)
        setBackgroundImage(UIImage(named: backgroudImageName), forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named: backgroudImageName + "_highlighted"), forState: UIControlState.Selected)
        //根据背景图片的大小调整按钮的尺寸
        sizeToFit()
    }
}